﻿package model.entity.product;

import java.util.Map;
import java.util.Map.Entry;

import javax.persistence.MappedSuperclass;

import model.business.product.ProductState;
import model.entity.Brand;

@MappedSuperclass
public class Electronic extends Product {

	protected String size;
	protected String warranty;
	protected String powerCosume;

	
	public Electronic() {
		super();
	}
	
	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public String getWarranty() {
		return warranty;
	}

	public void setWarranty(String warranty) {
		this.warranty = warranty;
	}

	public String getPowerCosume() {
		return powerCosume;
	}

	public void setPowerCosume(String powerCosume) {
		this.powerCosume = powerCosume;
	}

	public static Map<String, Class<?>> fieldMap(){
		Map<String, Class<?>> fieldMap = Product.fieldMap();
		fieldMap.put("size", String.class);
		fieldMap.put("warranty", String.class);
		fieldMap.put("powerCosume", String.class);
		return fieldMap;

	}
	
	@Override
	public void insertData(Map<String, Object> valueMap) {
		super.insertData(valueMap);
		for (Entry<String, Object> entry : valueMap.entrySet()) {
			Object value = entry.getValue();
			
			//Dk rong
			if(entry.getValue() == null) continue;
			
			switch (entry.getKey()) {
			case "size":
				this.size = (String) value;
				break;
			case "warranty":
				this.warranty = (String) value;
				break;
			case "powerCosume":
				this.powerCosume = (String) value;
				break;
			default:
				break;
			}
		}
	}
}
